Repository navigation
fix(windows): preserve Wintun identity after restart - #7
Merged
Merged
Conversation
Wait for Wintun's orphan cleanup after opening the adapter, then recreate the requested identity only after its device node disappears. This avoids unsupported WOW64 uninstall commands and preserves GUIDs. Reject a same-name adapter with a different GUID, and cover adapter identity and other-adapter traffic in the Windows tests.
zzxym
pushed a commit
to zzxym/rust-tun
that referenced
this pull request
Nov 14, 2026
Wait for Wintun's orphan cleanup after opening the adapter, then recreate the requested identity only after its device node disappears. This avoids unsupported WOW64 uninstall commands and preserves GUIDs. Reject a same-name adapter with a different GUID, and cover adapter identity and other-adapter traffic in the Windows tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A Windows process terminated while a Wintun adapter is active can leave its fixed device instance behind. Recreating the same adapter GUID can then fail with
0xC0000035or a device setup timeout.Change
Trigger Wintun's existing orphan cleanup through its public open operation and wait for the requested device instance to disappear before creating it. Keep the requested GUID and reject a same-name adapter with a different GUID. This avoids an external device-removal helper and supports WOW64 on Windows 10 1809.
Wintun's cleanup is asynchronous and scans Wintun devices globally. If cleanup does not complete, the caller receives a timeout; Wintun's initial synchronous open is not covered by that polling timeout.
Verification
cargo fmt --all -- --check; Windows x86 and x64 Clippy with existing lint exceptions; Linux library tests in therustcontainer (2 passed).Windows 11's UDP probe was blocked or otherwise affected by a host outbound firewall rule; its exact cause was not verified. The rust-tun repository's strict Clippy has existing unrelated lint failures and full
cargo testhas existing examples using the oldtun2crate name.Related: EasyTier/EasyTier#2770